<?php

namespace App\Http\Controllers\Api;

use App\Model\AdminLog;
use App\Model\Anonym;



use Illuminate\Http\Request;


class FullScreenController extends BaseController
{

    public $host;
    public function __construct(Request $request)
    {
        parent::__construct($request);
        $this->model = '';
        $this -> host = getKkaudioApiUrl();
    }



    public function add(Request $request){
        $input = $request -> input();
        $url = $this->host . '/inner/full/add';
        $res = curl_request($url, $input, 'json', 'POST');

        if ($res['code'] == 0) {
            AdminLog::createData($request, AdminLog::FULL_SCREEN, "添加飘萍");
            return $this->toJson(self::SUCCESS);
        }
        return $this->toJson(self::ERROR, [], $res['msg']??'失败');
    }
    public function edit(Request $request){
        $input = $request -> input();
        $url = $this->host . '/inner/full/edit';
        $res = curl_request($url, $input, 'json', 'POST');

        if ($res['code'] == 0) {
            AdminLog::createData($request, AdminLog::FULL_SCREEN, "编辑飘萍");
            return $this->toJson(self::SUCCESS);
        }
        return $this->toJson(self::ERROR, [], $res['msg']??'失败');
    }
    public function del(Request $request){
        $input = $request -> input();
        $url = $this->host . '/inner/full/del';
        $res = curl_request($url, $input, 'json', 'POST');

        if ($res['code'] == 0) {
            AdminLog::createData($request, AdminLog::FULL_SCREEN, "删除飘萍");
            return $this->toJson(self::SUCCESS);
        }
        return $this->toJson(self::ERROR, [], $res['msg']??'失败');
    }

    public function fullList(Request $request){
        $input = [];//$request -> input();
        $url = $this->host . '/inner/full/list';
        $res = curl_request($url, $input, 'urlencoded', 'GET');

        if ($res['code'] == 0) {
            return $this->toJson(self::SUCCESS, $res['data']);
        }
        return $this->toJson(self::ERROR, [], $res['msg']??'失败');

    }

    public function getFullPage(Request $request){
        $input = [];//$request -> input();
        $url = $this->host . '/inner/full/get_full_page';
        $res = curl_request($url, $input, 'urlencoded', 'GET');

        if ($res['code'] == 0) {
            return $this->toJson(self::SUCCESS, $res['data']);
        }
        return $this->toJson(self::ERROR, [], $res['msg']??'失败');

    }

    public function getFullScreen(Request $request){
        $input = $request -> input();
        $url = $this->host . '/inner/full/get_full_screen';
        $res = curl_request($url, $input, 'urlencoded', 'GET');

        if ($res['code'] == 0) {
            return $this->toJson(self::SUCCESS, $res['data']);
        }
        return $this->toJson(self::ERROR, [], $res['msg']??'失败');
    }
}
